package cn.tedu._03vehicle.pojo.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.*;
import lombok.Data;

@Data
public class UserRegParam {
    //@NotNull(message = "用户名不能为null")
    //@NotEmpty(message = "用户名不能为null和空字符串")
    //@NotBlank(message = "用户名不能为null和空字符串和空白串")
    //@Size(min = 3, max = 10, message = "用户名长度必须在3-10之间")
    @Pattern(regexp = "^([a-zA-Z]{0,14}|[\\u4e00-\\u9fa5]{0,7})$",
            message = "用户名最长为14个英文或者7个汉字")
    @Schema(description = "用户名", required = true, example = "admin")
    private String username;

    /*
        密码合法性要求如下:
        1.长度为8-14个字符;
        2.字符/数字以及标点符号至少包含2种;
        3.不允许有空格、中文;
     */
    @Pattern(regexp = "^(?!.*[\\u4e00-\\u9fff\\s])(?=.*[a-zA-Z\\d])(?=.*[\\W_])(?=.{8,14}$)[\\x21-\\x7e]+$|^(?!.*[\\u4e00-\\u9fff\\s])(?=.[a-zA-Z])(?=.\\d)(?=.{8,14}$)[\\x21-\\x7e]+$|^(?!.*[\\u4e00-\\u9fff\\s])(?=.*[\\W_])(?=.*\\d)(?=.{8,14}$)[\\x21-\\x7e]+$", message = "密码不合法")
    @Schema(description = "密码", required = true, example = "123456")
    private String password;

    //@Email(message = "邮箱格式错误")
    @Pattern(regexp = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.(cn|com\\.cn|net\\.cn|org\\.cn|gov\\.cn|edu\\.cn|mil\\.cn|ac\\.cn)$", message = "邮箱格式错误")
    @Schema(description = "邮箱", required = true, example = "admin@163.com")
    private String email;
    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号不合法")
    @Schema(description = "手机号码", required = true, example = "13888888888")
    private String phone;
}
